"""server URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from rest_framework.routers import DefaultRouter
from django.urls import path, include
from rest_framework_jwt.views import obtain_jwt_token

DEBUG = True
VERSION = "v1"
router = DefaultRouter(trailing_slash=False)

router.include_root_view = False

urlpatterns = router.urls


swagger_info = openapi.Info(
    title="django-rest-example",
    default_version=VERSION,
    description="""
        django-rest-example
    """,
)

SchemaView = get_schema_view(
    info=swagger_info,
    validators=["flex"],
    public=True,
    permission_classes=(permissions.AllowAny,),
)


urlpatterns += [
    path("admin-dashboard/", admin.site.urls),
    path("test/", include(("api.routes.hello.urls", "api"), namespace="api")),
    path("token", obtain_jwt_token),
]

if DEBUG:
    urlpatterns += [
        path("docs/", SchemaView.with_ui("swagger", cache_timeout=0), name="docs"),
        path("redoc/", SchemaView.with_ui("redoc", cache_timeout=0), name="redoc"),
    ]
